﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using POS.USBScanner;

namespace Tests
{
    public partial class Form1 : Form
    {
        BarcodeScannerListener listener;

        public Form1()
        {
            InitializeComponent();
            this.Shown += new System.EventHandler(this.Form1_Shown);
        }



        private void OnBarcodeScanned(object sender, EventArgs e)
        {
            BarcodeScannedEventArgs be;

            be = e as BarcodeScannedEventArgs;
            if (be != null)
            {
                string message;

                message = string.Format(
                    CultureInfo.CurrentCulture,
                    "You scanned {0} from device '{1}'.",
                    be.Barcode,
                    be.DeviceInfo.FriendlyName);

                System.Diagnostics.Debug.WriteLine(message);
                MessageBox.Show(message);
            }
        }

        private void Form1_Shown(object sender, EventArgs e)
        {

            listener = new BarcodeScannerListener();
            listener.BarcodeScanned += this.OnBarcodeScanned;
        }
    }
}
